# Maintainer: Joel Holdsworth <jholdsworth@nvidia.com>

_realname=conan
pkgbase=mingw-w64-python-conan
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.16.1
pkgrel=1
pkgdesc="A distributed, open source, C/C++ package manager (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'aur: conan'
  'purl: pkg:pypi/conan'
)
license=('spdx:MIT')
msys2_repository_url='https://github.com/conan-io/conan/'
msys2_documentation_url='https://docs.conan.io/2/'
msys2_issue_tracker_url='https://github.com/conan-io/conan/issues/'
url='https://conan.io/'
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-urllib3"
         "${MINGW_PACKAGE_PREFIX}-python-colorama"
         "${MINGW_PACKAGE_PREFIX}-python-yaml"
         "${MINGW_PACKAGE_PREFIX}-python-patch-ng"
         "${MINGW_PACKAGE_PREFIX}-python-fasteners"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-dateutil"
         "${MINGW_PACKAGE_PREFIX}-python-bottle"
         "${MINGW_PACKAGE_PREFIX}-python-pluginbase"
         "${MINGW_PACKAGE_PREFIX}-python-pyjwt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
        "0001-urllib3-req.patch")
sha256sums=('e5b2aac9dab4f23e95f62a7c62dfb33c5f4522fab34332120c8be6eca11f5bec'
            '731de256a4612cdfea37398e96af5811574ff8d11485200dc643b6352cd46395')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # https://github.com/conan-io/conan/issues/13948
  patch -Np1 -i "${srcdir}/0001-urllib3-req.patch"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE.md "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
}
